module.exports = function($scope, $state, $stateParams, $modalInstance, $modal, $resource,FileUploader,toaster, item, date2str, str2date, type, flag){
  $scope.vm = {
      'date' : '',
      'options' : {
          format: "YYYY-MM-DD",
          locale : 'zh-cn'
      }
  }
  $scope.type = type;
  $scope.flag = flag;
  console.log($scope.type, $scope.flag);
  $scope.info = item;
  console.log($scope.info);
  if($scope.info.content != undefined){
    $scope.array = $scope.info.content.split(',');
  }
  console.log($scope.info.push_time);
  if($scope.info.push_time != undefined){
      $scope.vm.date = str2date($scope.info.push_time);
  }
  $scope.ok = function(){
    $scope.info.push_time = date2str($scope.vm.date._d);
    $resource('/api/ac/goc/hotelNoiceService/createViewNotice', {}, {}).
    save($scope.info,function(res) {
        if (res.errcode !== 0) {
            toaster.error({title:"",body:res.errmsg});
            return;
        }
        console.log(res);
        toaster.success({title:"",body:"操作成功"});
        $modalInstance.close();
    })
  }
  $scope.cancel = function(){
    $modalInstance.close();
  }
  $scope.image = function(){
    var para = $state.get('app.imageupload');
    //设置上传文件夹，以自己业务命名
    angular.extend(para, {
      resolve : {  
        'dir' : function(){
          return 't1';
        }
      }  
    })
    var modalInstance = $modal.open(para);
    modalInstance.opened.then(function() {// 模态窗口打开之后执行的函数  
      console.log('modal is opened');  
    });  
    modalInstance.result.then(function(result) {  
      console.log(result);  
      // $scope.imagearr = JSON.stringify(result);
      $scope.array = result;
      $scope.info.content = $scope.array.join(',');
      console.log($scope.array.join(',')
    );
    }, function(reason) {  
      console.log(reason);// 点击空白区域，总会输出backdrop  
      // click，点击取消，则会暑促cancel  
      $log.info('Modal dismissed at: ' + new Date());  
    }); 
  };
  

};